<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!-- 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function getTotalTarget(name){
		var objs = document.getElementsByName(name);
		var total = 0;
		for(var i = 0; i < objs.length; i++){
			total = total + Number(objs[i].value);
		}
		document.getElementById("totalTargets").innerText = Math.round(total * 100) / 100;
		document.getElementById("totalTarget").value = Math.round(total * 100) / 100;
	}
	
	function initPage(){
		getTotalTarget('januaryTarget');
	}
-->
</script>
</head>
<body style="margin: 0 0 0 0;" onload="initPage()">
<form name="updateMonthTarget" action="" method="post">
	<div id="d" style="width:100%;height:390px;overflow-x: hidden;overflow-y: scroll;">
	<table cellpadding="0" cellspacing="0" class="table_style">
		<tr>
			<td class="title3" colspan="13" align="right">
				<fmt:message key='common.lable.unit'/>&nbsp;&nbsp;<fmt:message key='common.lable.yuan'/>&nbsp;&nbsp;
			</td>
		</tr>
		<tr>
			<td class="title" width="15%"><fmt:message key='target.lable.assignObject'/></td>
			<td class="title" colspan="12"></td>
		</tr>
		<c:forEach var="dept" items="${monthTargets}">
		<tr>
			<td colspan="13" class="title4">${dept.deptName}</td>							
		</tr>
			<c:forEach var="user" items="${dept.users}">
			<tr>
				<td class="">${user.userName}<input id="userId" name="userId" type="hidden" value="${user.id}"/></td>
				<td colspan="12" align="center">
					<fmt:formatNumber var="yearTarget" value='${user.businessTarget.yearTarget}' pattern='############'/>
					<input id="januaryTarget" name="januaryTarget" class="input2" type="text" size="15" 
						onblur="getTotalTarget('januaryTarget')" onkeyup="onlyNumFloat(this)" 
						value="<c:choose><c:when test='${yearTarget != null}'>${yearTarget}</c:when><c:otherwise>0</c:otherwise></c:choose>"/>
				</td>
			</tr>
			</c:forEach>
		</c:forEach>
		<tr>
			<td class="title"><fmt:message key='common.lable.total'/></td>
	        <td class="title" colspan="12" style="text-align: center;">
            	<span id="totalTargets"></span>
            	<input id="totalTarget" name="totalTarget" type="hidden" value="0"/>
            </td>
		</tr>
</table>
</div>
</form>
</body>
</html>